package main

import "fmt"
//定义接口
type Printer interface {
	//打印方法
	Print(interface{})
}
//定义函数为类型
type FuncCaller func(p interface{})
//实现Printer的Print方法
func (FuncCaller FuncCaller) Print(p interface{})  {
	//调用funcCaller函数本体
	FuncCaller(p)
}

type Cat interface {
	CatchMouse()
}

type Dog interface {
	Bark()
}

type CatDog struct {
	Name string
}

func (catDog *CatDog)CatchMouse()  {
	fmt.Printf("%v caught the mouse and ate it!\n",catDog.Name)
}
func (catDog CatDog) Bark()  {
	fmt.Printf("%v barked loudly!\n",catDog.Name)
}
func main() {
	var printer Printer
	//将李明函数强制转为FuncCaller赋值给printer
	printer = FuncCaller(func(p interface{}) {
		fmt.Println(p)
	})
	printer.Print("Golang is Good!")
	fmt.Println("-----------------")
	catDog := &CatDog{
		"Lucy",
	}
	var cat Cat
	cat = catDog
	cat.CatchMouse()
	fmt.Println("-----------------")
	var dog Dog
	dog = catDog
	dog.Bark()
	fmt.Println("-----------------")
	catDog.CatchMouse()
	catDog.Bark()
	fmt.Println("-----------------")
	sayHello()
}
